<html>
<head><meta charset="utf-8"><title>Clarification: Can you have &amp;T and *mut T point at the sa... · t-lang/wg-unsafe-code-guidelines · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/index.html">t-lang/wg-unsafe-code-guidelines</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html">Clarification: Can you have &amp;T and *mut T point at the sa...</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="169252240"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169252240" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169252240">(Jun 28 2019 at 18:54)</a>:</h4>
<p>Assuming that the <code>*mut T</code> is not used to mutate the value, is it legal to have it point to the same location as a live <code>&amp;T</code> points at?</p>



<a name="169252296"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169252296" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169252296">(Jun 28 2019 at 18:55)</a>:</h4>
<p>in general yes, though it also matters how the ptrs got created</p>



<a name="169252421"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169252421" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169252421">(Jun 28 2019 at 18:56)</a>:</h4>
<p>if you created the <code>*mut T</code> <em>from</em> the <code>&amp;T</code> the certainly yes</p>



<a name="169252434"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169252434" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169252434">(Jun 28 2019 at 18:57)</a>:</h4>
<p>(via <code>my_ref as *const _ as *mut T</code>)</p>



<a name="169252470"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169252470" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169252470">(Jun 28 2019 at 18:57)</a>:</h4>
<p>if it's derived from a parent of <code>&amp;T</code>, then other things you did before might have already killed that pointer</p>



<a name="169252484"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169252484" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169252484">(Jun 28 2019 at 18:57)</a>:</h4>
<p>also anything I say is "assuming Stacked Borrows", which is not normative etc ;)</p>



<a name="169252563"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169252563" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169252563">(Jun 28 2019 at 18:58)</a>:</h4>
<p>I think it's the other way around. Ptr all the time, some of the time a &amp;T is made from it temporarily</p>



<a name="169252626"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169252626" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169252626">(Jun 28 2019 at 18:59)</a>:</h4>
<p>you are making the &amp;T directly from the *mut T?</p>



<a name="169252645"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169252645" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169252645">(Jun 28 2019 at 18:59)</a>:</h4>
<p>then your code would even be safe if you replaced <code>*mut T</code> by <code>&amp;mut T</code>, so yes definitely allowed</p>



<a name="169252662"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169252662" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169252662">(Jun 28 2019 at 18:59)</a>:</h4>
<p>uh, i think. They've been updating some old async locking code</p>



<a name="169252673"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169252673" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169252673">(Jun 28 2019 at 18:59)</a>:</h4>
<p>that's like</p>
<div class="codehilite"><pre><span></span><span class="kd">let</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">&amp;</span><span class="k">mut</span><span class="w"> </span><span class="mi">42</span><span class="p">;</span><span class="w"></span>
<span class="kd">let</span><span class="w"> </span><span class="n">x_shr</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">&amp;*</span><span class="n">x</span><span class="p">;</span><span class="w"></span>
<span class="kd">let</span><span class="w"> </span><span class="n">_val</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">*</span><span class="n">x</span><span class="p">;</span><span class="w"></span>
<span class="kd">let</span><span class="w"> </span><span class="n">_val</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">*</span><span class="n">x_shr</span><span class="p">;</span><span class="w"></span>
<span class="kd">let</span><span class="w"> </span><span class="n">_val</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">*</span><span class="n">x</span><span class="p">;</span><span class="w"></span>
</pre></div>



<a name="169252734"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169252734" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169252734">(Jun 28 2019 at 19:00)</a>:</h4>
<p>as you can see we can use both interchangabky</p>



<a name="169252755"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169252755" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169252755">(Jun 28 2019 at 19:00)</a>:</h4>
<p>They've been guided to use NonNull&lt;T&gt; instead of a raw pointer and then make either &amp;T or &amp;mut T depending of the type of lock the user takes on the data, which seems right</p>



<a name="169252808"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169252808" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169252808">(Jun 28 2019 at 19:01)</a>:</h4>
<p><code>NonNull</code> is a raw ptr though</p>



<a name="169252809"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169252809" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169252809">(Jun 28 2019 at 19:01)</a>:</h4>
<p>just wrapped</p>



<a name="169252823"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169252823" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169252823">(Jun 28 2019 at 19:01)</a>:</h4>
<p>so that part doesnt change anything</p>



<a name="169252921"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169252921" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169252921">(Jun 28 2019 at 19:02)</a>:</h4>
<p>Yeah that's what I thought :/</p>



<a name="169253364"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169253364" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169253364">(Jun 28 2019 at 19:07)</a>:</h4>
<p>So <code>NonNull</code> has a niche, and <code>*const</code> doesn't allow writing directly to the value, but they're both otherwise effectively the same as <code>*mut</code>. It's just one "raw pointer" concept at the heart of all three?</p>



<a name="169253776"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169253776" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169253776">(Jun 28 2019 at 19:12)</a>:</h4>
<p>basically, yes</p>



<a name="169253799"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169253799" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169253799">(Jun 28 2019 at 19:12)</a>:</h4>
<p>with the one small caveat that <code>&amp;mut foo as *const T</code> implicitly goes through <code>&amp;T</code></p>



<a name="169253819"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169253819" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169253819">(Jun 28 2019 at 19:13)</a>:</h4>
<p>so, which type you cast to affects which intermediate reference gets created</p>



<a name="169253838"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169253838" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169253838">(Jun 28 2019 at 19:13)</a>:</h4>
<p>and shared references cannot be written to so this makes a difference</p>



<a name="169253851"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169253851" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169253851">(Jun 28 2019 at 19:13)</a>:</h4>
<p>(that's at least what happens currently, I hope we can change that, but that might be hard)</p>



<a name="169257414"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169257414" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169257414">(Jun 28 2019 at 19:59)</a>:</h4>
<p>that's a bit of a footgun technicality for sure</p>



<a name="169257748"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169257748" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169257748">(Jun 28 2019 at 20:02)</a>:</h4>
<p><a href="https://github.com/64/spin-rs/blob/master/src/rw_lock.rs" target="_blank" title="https://github.com/64/spin-rs/blob/master/src/rw_lock.rs">https://github.com/64/spin-rs/blob/master/src/rw_lock.rs</a> is apparently the full module they're working on, but it's like 700 lines so i don't expect folks to necessarily inspect it all. The crate does seem to get on the order of thousands of downloads a month though, so an eventual careful inspection wouldn't be out of place</p>



<a name="169257940"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169257940" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matt Taylor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169257940">(Jun 28 2019 at 20:04)</a>:</h4>
<p>i'm the author, would appreciate if you could take a look. i'm fixing an issue with the variance of the RAII guards atm</p>



<a name="169258096"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169258096" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169258096">(Jun 28 2019 at 20:06)</a>:</h4>
<p>makes me wonder if you couldnt use <code>parking_lot</code> with a custom parking implementation that just spins, to avoid having to reimplement all these concurrency primitives?</p>



<a name="169258124"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169258124" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matt Taylor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169258124">(Jun 28 2019 at 20:07)</a>:</h4>
<p>it's supposed to be no_std, so i'm not sure how easy that would be</p>



<a name="169258146"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169258146" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169258146">(Jun 28 2019 at 20:07)</a>:</h4>
<p>not sure either^^ sorry didnt mean it was obvious or so</p>



<a name="169258169"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169258169" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169258169">(Jun 28 2019 at 20:07)</a>:</h4>
<p>just thinking of ways to maximize sharing with existing well-reviewed well-tested code :D</p>



<a name="169259050"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169259050" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Shnatsel <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169259050">(Jun 28 2019 at 20:19)</a>:</h4>
<p><span class="user-mention" data-user-id="228354">@Matt Taylor</span> someone in #black-magic in Rust Community Discord is combing through it for the past day or so. Perhaps you should chat. <a href="https://bit.ly/rust-community" target="_blank" title="https://bit.ly/rust-community">https://bit.ly/rust-community</a></p>



<a name="169259087"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169259087" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matt Taylor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169259087">(Jun 28 2019 at 20:19)</a>:</h4>
<p>i've successfully managed to impersonate myself, in that case</p>



<a name="169259139"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169259139" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matt Taylor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169259139">(Jun 28 2019 at 20:20)</a>:</h4>
<p>[that's me :^)]</p>



<a name="169259824"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169259824" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169259824">(Jun 28 2019 at 20:33)</a>:</h4>
<p>now <em>that's</em> some effective identity theft</p>



<a name="169269011"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169269011" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matt Taylor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169269011">(Jun 28 2019 at 22:52)</a>:</h4>
<p>looks like we're going to need some further clarification: is this UB?</p>
<div class="codehilite"><pre><span></span><span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">v</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0_</span><span class="k">i32</span><span class="p">;</span><span class="w"></span>
<span class="kd">let</span><span class="w"> </span><span class="n">ptr</span>: <span class="o">*</span><span class="k">const</span><span class="w"> </span><span class="kt">i32</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">&amp;</span><span class="n">v</span><span class="p">;</span><span class="w"></span>
<span class="p">{</span><span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="n">_y</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">&amp;</span><span class="k">mut</span><span class="w"> </span><span class="n">v</span><span class="p">;</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="kd">let</span><span class="w"> </span><span class="n">_z</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">unsafe</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="o">*</span><span class="n">ptr</span><span class="w"> </span><span class="p">};</span><span class="w"></span>
</pre></div>



<a name="169269027"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169269027" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matt Taylor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169269027">(Jun 28 2019 at 22:52)</a>:</h4>
<p>miri flags the last line as UB</p>



<a name="169272112"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169272112" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169272112">(Jun 28 2019 at 23:47)</a>:</h4>
<p>I believe so, yeah. Imagine there were two threads and the pointer was in one and the reference in another. This would allow for a data race (UB).</p>



<a name="169272169"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169272169" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169272169">(Jun 28 2019 at 23:48)</a>:</h4>
<p>note that data race is a result of invoking UB, in this case having mutable reference and "live" pointer to the same thing at the same time.</p>



<a name="169272193"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169272193" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169272193">(Jun 28 2019 at 23:49)</a>:</h4>
<p>Though that’s just my interpretation and the official answer and exact wording may be different.</p>



<a name="169272450"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169272450" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169272450">(Jun 28 2019 at 23:55)</a>:</h4>
<p>I think we are going to need some super simple examples like this one to teach stacked borrows.</p>



<a name="169272457"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169272457" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169272457">(Jun 28 2019 at 23:55)</a>:</h4>
<p>And we don't only need to teach how it works, but also, why it works this way.</p>



<a name="169272466"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169272466" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169272466">(Jun 28 2019 at 23:56)</a>:</h4>
<p>This example would be better if it would make a potential pitfall clearer</p>



<a name="169272684"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169272684" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169272684">(Jun 29 2019 at 00:00)</a>:</h4>
<p>Maybe start with:</p>
<div class="codehilite"><pre><span></span><span class="k">struct</span> <span class="nc">P</span><span class="p">(</span><span class="o">*</span><span class="k">const</span><span class="w"> </span><span class="kt">i32</span><span class="p">);</span><span class="w"></span>
<span class="k">unsafe</span><span class="w"> </span><span class="k">impl</span><span class="w"> </span><span class="nb">Send</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">P</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">v</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0_</span><span class="k">i32</span><span class="p">;</span><span class="w"></span>
<span class="kd">let</span><span class="w"> </span><span class="n">ptr</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">P</span><span class="p">(</span><span class="o">&amp;</span><span class="n">v</span><span class="p">);</span><span class="w"></span>
<span class="kd">let</span><span class="w"> </span><span class="n">h</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">std</span>::<span class="n">thread</span>::<span class="n">spawn</span><span class="p">(</span><span class="o">||</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">y</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">&amp;</span><span class="k">mut</span><span class="w"> </span><span class="n">v</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="o">*</span><span class="n">y</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">3</span><span class="p">;</span><span class="w"></span>
<span class="p">});</span><span class="w"></span>
<span class="kd">let</span><span class="w"> </span><span class="n">_z</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">unsafe</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="o">*</span><span class="n">ptr</span><span class="p">.</span><span class="mi">0</span><span class="w"> </span><span class="p">};</span><span class="w"> </span><span class="c1">// data-race</span>
<span class="n">h</span><span class="p">.</span><span class="n">join</span><span class="p">();</span><span class="w"></span>
</pre></div>



<a name="169272721"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169272721" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matt Taylor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169272721">(Jun 29 2019 at 00:01)</a>:</h4>
<p>i definitely agree on that, i haven't been doing rust as long as some people here but these things seem are quite subtle and somehow i haven't heard about them before</p>



<a name="169272744"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169272744" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matt Taylor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169272744">(Jun 29 2019 at 00:02)</a>:</h4>
<p>what confuses me is that you could in theory synchronise access and make sure that the accesses on different threads never happen at the same time (eg by using an atomic)</p>



<a name="169272788"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169272788" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169272788">(Jun 29 2019 at 00:02)</a>:</h4>
<p>you could, but the code doesn't do that</p>



<a name="169272798"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169272798" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matt Taylor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169272798">(Jun 29 2019 at 00:02)</a>:</h4>
<p>but the single threaded variant effectively synchronises them</p>



<a name="169273198"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169273198" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169273198">(Jun 29 2019 at 00:12)</a>:</h4>
<p>weird the spawn code is ok</p>



<a name="169273216"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169273216" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matt Taylor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169273216">(Jun 29 2019 at 00:13)</a>:</h4>
<p>i didn't think miri could deal with multiple threads yet? (assuming gnzlbg is talking about miri)<br>
<a href="https://github.com/rust-lang/miri/issues/789#issuecomment-505201476" target="_blank" title="https://github.com/rust-lang/miri/issues/789#issuecomment-505201476">https://github.com/rust-lang/miri/issues/789#issuecomment-505201476</a></p>



<a name="169273279"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169273279" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matt Taylor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169273279">(Jun 29 2019 at 00:14)</a>:</h4>
<p>'for example, Miri currently does not support concurrency' from the readme</p>



<a name="169273360"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169273360" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169273360">(Jun 29 2019 at 00:16)</a>:</h4>
<p><span class="user-mention" data-user-id="228354">@Matt Taylor</span> <a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=12c5c1a90341a63f7c5a4d66520321a1" target="_blank" title="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=12c5c1a90341a63f7c5a4d66520321a1">https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=12c5c1a90341a63f7c5a4d66520321a1</a></p>



<a name="169273362"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169273362" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169273362">(Jun 29 2019 at 00:16)</a>:</h4>
<p>that fails under miri</p>



<a name="169273377"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169273377" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169273377">(Jun 29 2019 at 00:17)</a>:</h4>
<p>(I had to adapt the signature of spawn a bit - I guess for an example something like crossbeam::scope would be better)</p>



<a name="169273463"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169273463" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matt Taylor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169273463">(Jun 29 2019 at 00:20)</a>:</h4>
<p>yeah, makes sense given that the original example i posted is UB</p>



<a name="169274803"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169274803" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169274803">(Jun 29 2019 at 00:57)</a>:</h4>
<p>it doesn't make sense that the 4 line example is UB given that it's clearly all in a single thread</p>



<a name="169274814"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169274814" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169274814">(Jun 29 2019 at 00:57)</a>:</h4>
<p>i mean there's a lot of code that's UB if you suddenly make it multi-threaded, that doesn't make it UB single threaded</p>



<a name="169276057"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169276057" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169276057">(Jun 29 2019 at 01:35)</a>:</h4>
<p><span class="user-mention" data-user-id="224471">@Lokathor</span> Rust’s mutable references introduce certain requirements to the code which you are not supposed to violate. One of them is no aliasing. This is what ultimately makes even something like this UB, even if you never really cause a data race to happen. The reason why I bought up the data race is because that is the most trivial way to demonstrate issues manifesting due to violating such kind of UB.</p>



<a name="169276100"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169276100" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169276100">(Jun 29 2019 at 01:36)</a>:</h4>
<p>Now, whether just having a mutable reference <em>and</em> an aliased, but "dead" (unused) pointer is a problem is another question altogether. However in their case the pointer is live which makes that particular piece of code UB.</p>



<a name="169276286"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169276286" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169276286">(Jun 29 2019 at 01:43)</a>:</h4>
<p>this is unfortunate and terrible</p>



<a name="169289595"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169289595" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169289595">(Jun 29 2019 at 09:10)</a>:</h4>
<blockquote>
<p>looks like we're going to need some further clarification: is this UB?</p>
<div class="codehilite"><pre><span></span><span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">v</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0_</span><span class="k">i32</span><span class="p">;</span><span class="w"></span>
<span class="kd">let</span><span class="w"> </span><span class="n">ptr</span>: <span class="o">*</span><span class="k">const</span><span class="w"> </span><span class="kt">i32</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">&amp;</span><span class="n">v</span><span class="p">;</span><span class="w"></span>
<span class="p">{</span><span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="n">_y</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">&amp;</span><span class="k">mut</span><span class="w"> </span><span class="n">v</span><span class="p">;</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="kd">let</span><span class="w"> </span><span class="n">_z</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">unsafe</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="o">*</span><span class="n">ptr</span><span class="w"> </span><span class="p">};</span><span class="w"></span>
</pre></div>


</blockquote>
<p>Miri flags this as UB because then you create a new mutable reference like <code>_y</code>, you are asserting that it is the only pointing to whatever-you-crated-it-from -- that's <code>v</code> in this case. So anything that already exists that points to <code>v</code> is now invalid.</p>



<a name="169289603"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169289603" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169289603">(Jun 29 2019 at 09:11)</a>:</h4>
<p>it's not really about concurrency at all, in my mind</p>



<a name="169289604"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169289604" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169289604">(Jun 29 2019 at 09:11)</a>:</h4>
<p>the point is that we'd like to optimize assuming that mutable references are unique</p>



<a name="169289606"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169289606" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169289606">(Jun 29 2019 at 09:11)</a>:</h4>
<p>and this code violates (some interpretation of) that uniqueness requirement</p>



<a name="169289648"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169289648" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169289648">(Jun 29 2019 at 09:12)</a>:</h4>
<p>however, also see <a href="https://github.com/rust-lang/unsafe-code-guidelines/issues/133" target="_blank" title="https://github.com/rust-lang/unsafe-code-guidelines/issues/133">https://github.com/rust-lang/unsafe-code-guidelines/issues/133</a>: I am aware that this asserting-uniqueness-on-creation is very aggressive, and maybe there is a way to do better here, i.e. to allow more code without losing (most) optimizations.</p>



<a name="169289663"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169289663" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169289663">(Jun 29 2019 at 09:13)</a>:</h4>
<p><span class="user-mention" data-user-id="224471">@Lokathor</span> <span class="user-mention" data-user-id="228354">@Matt Taylor</span> question while I got your attention, how surprised are you by this code being UB? Any variant of Stacked Borrows that I can imagine makes this UB:</p>
<div class="codehilite"><pre><span></span><span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">v</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0_</span><span class="k">i32</span><span class="p">;</span><span class="w"></span>
<span class="kd">let</span><span class="w"> </span><span class="n">ptr</span>: <span class="o">*</span><span class="k">const</span><span class="w"> </span><span class="kt">i32</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">&amp;</span><span class="n">v</span><span class="p">;</span><span class="w"></span>
<span class="p">{</span><span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="n">y</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">&amp;</span><span class="k">mut</span><span class="w"> </span><span class="n">v</span><span class="p">;</span><span class="w"> </span><span class="o">*</span><span class="n">y</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="kd">let</span><span class="w"> </span><span class="n">_z</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">unsafe</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="o">*</span><span class="n">ptr</span><span class="w"> </span><span class="p">};</span><span class="w"></span>
</pre></div>



<a name="169289665"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169289665" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169289665">(Jun 29 2019 at 09:13)</a>:</h4>
<p>now the mutable reference gets used for an <em>access</em>, and at that point definitely it cannot have any aliases</p>



<a name="169297215"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169297215" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169297215">(Jun 29 2019 at 13:25)</a>:</h4>
<p>Retep998 strongly believes that such code is not supposed to be UB because a pointer has no rules beyond C rules, and in C you could do that, and so _even if_ Rust rules apply while a reference exists (which is fair), basically once the reference stops existing things should "revert" to just being normal pointer-only rules, including a restoration of the <code>*const</code> pointer.</p>



<a name="169297272"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169297272" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169297272">(Jun 29 2019 at 13:26)</a>:</h4>
<p>i tend to agree</p>



<a name="169297600"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169297600" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169297600">(Jun 29 2019 at 13:34)</a>:</h4>
<p>Can you do that even if you mix it with a <code>restrict</code> pointer to the same memory location ?</p>



<a name="169297666"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169297666" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169297666">(Jun 29 2019 at 13:37)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="kt">int</span> <span class="n">v</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
<span class="kt">int</span> <span class="k">const</span><span class="o">*</span> <span class="n">ptr</span> <span class="o">=</span> <span class="o">&amp;</span><span class="n">v</span><span class="p">;</span>
<span class="p">{</span> <span class="kt">int</span><span class="o">*</span> <span class="kr">restrict</span> <span class="n">y</span> <span class="o">=</span> <span class="o">&amp;</span><span class="n">v</span><span class="p">;</span> <span class="o">*</span><span class="n">y</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span> <span class="p">}</span>
<span class="kt">int</span> <span class="n">z</span> <span class="o">=</span> <span class="o">*</span><span class="n">ptr</span><span class="p">;</span> <span class="c1">// OK ?</span>
</pre></div>



<a name="169297894"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169297894" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169297894">(Jun 29 2019 at 13:45)</a>:</h4>
<p>This is definitely UB in C:</p>
<div class="codehilite"><pre><span></span><span class="kt">int</span> <span class="n">v</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
<span class="kt">int</span> <span class="k">const</span><span class="o">*</span> <span class="n">ptr</span> <span class="o">=</span> <span class="o">&amp;</span><span class="n">v</span><span class="p">;</span>
<span class="kt">int</span><span class="o">*</span> <span class="kr">restrict</span> <span class="n">y</span> <span class="o">=</span> <span class="o">&amp;</span><span class="n">v</span><span class="p">;</span>
<span class="kt">int</span> <span class="n">z</span> <span class="o">=</span> <span class="o">*</span><span class="n">ptr</span><span class="p">;</span> <span class="c1">// UB</span>
<span class="o">*</span><span class="n">y</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span>
</pre></div>


<p>you can't access v via ptr because there is a restrict pointer to v in that scope that modifies it.</p>



<a name="169297951"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169297951" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169297951">(Jun 29 2019 at 13:46)</a>:</h4>
<p>I suppose that the first example is OK in C, because the access doesn't happen in the scope of the restrict pointer, but this is also UB in C:</p>
<div class="codehilite"><pre><span></span><span class="kt">int</span> <span class="n">v</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
<span class="kt">int</span> <span class="k">const</span><span class="o">*</span> <span class="n">ptr</span> <span class="o">=</span> <span class="o">&amp;</span><span class="n">v</span><span class="p">;</span>
<span class="kt">int</span><span class="o">*</span> <span class="kr">restrict</span> <span class="n">y</span> <span class="o">=</span> <span class="o">&amp;</span><span class="n">v</span><span class="p">;</span> <span class="o">*</span><span class="n">y</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span>
<span class="kt">int</span> <span class="n">z</span> <span class="o">=</span> <span class="o">*</span><span class="n">ptr</span><span class="p">;</span> <span class="c1">// UB</span>
</pre></div>


<p>(just removed the <code>{}</code> of the first example, increasing the scope of restrict)</p>



<a name="169300239"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169300239" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169300239">(Jun 29 2019 at 14:44)</a>:</h4>
<blockquote>
<p>Retep998 strongly believes that such code is not supposed to be UB because a pointer has no rules beyond C rules, and in C you could do that, and so _even if_ Rust rules apply while a reference exists (which is fair), basically once the reference stops existing things should "revert" to just being normal pointer-only rules, including a restoration of the <code>*const</code> pointer.</p>
</blockquote>
<p>the pointer has no rules, but the reference does</p>



<a name="169300243"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169300243" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169300243">(Jun 29 2019 at 14:44)</a>:</h4>
<p>if you use <em>only</em> pointers, you wont have a problem</p>



<a name="169300256"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169300256" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169300256">(Jun 29 2019 at 14:45)</a>:</h4>
<p>but you are mixing references with pointers. we <em>have to</em> make this UB if we want to get any benefit from  our aliasing.</p>



<a name="169300316"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169300316" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169300316">(Jun 29 2019 at 14:46)</a>:</h4>
<p>if I applied your argument, the following code would be fine:</p>
<div class="codehilite"><pre><span></span><span class="k">fn</span> <span class="nf">foo</span><span class="p">(</span><span class="n">x</span>: <span class="kp">&amp;</span><span class="nc">mut</span><span class="w"> </span><span class="kt">i32</span><span class="p">,</span><span class="w"> </span><span class="n">y</span>: <span class="o">*</span><span class="k">mut</span><span class="w"> </span><span class="kt">i32</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="c1">// Note that we emit noalias here, telling LLVM these don&#39;t alias!</span>
<span class="p">}</span><span class="w"></span>

<span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">local</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">4</span><span class="p">;</span><span class="w"></span>
<span class="kd">let</span><span class="w"> </span><span class="n">raw</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">&amp;</span><span class="k">mut</span><span class="w"> </span><span class="n">local</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="o">*</span><span class="k">mut</span><span class="w"> </span><span class="n">_</span><span class="p">;</span><span class="w"></span>
<span class="n">foo</span><span class="p">(</span><span class="o">&amp;</span><span class="k">mut</span><span class="w"> </span><span class="n">local</span><span class="p">,</span><span class="w"> </span><span class="n">raw</span><span class="p">);</span><span class="w"> </span><span class="c1">// *oops*</span>
</pre></div>



<a name="169300331"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169300331" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169300331">(Jun 29 2019 at 14:47)</a>:</h4>
<p>so <span class="user-mention" data-user-id="224471">@Lokathor</span> the only way to make such code not UB and do what Retep998 suggests is to <em>remove</em> the aliasing optimizations that we are already performing</p>



<a name="169300364"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169300364" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169300364">(Jun 29 2019 at 14:48)</a>:</h4>
<p>"stops existing" is not something I think we can formalize, and scopes clearly shouldnt matter</p>



<a name="169300383"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169300383" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169300383">(Jun 29 2019 at 14:48)</a>:</h4>
<p>so my code is the same as</p>
<div class="codehilite"><pre><span></span><span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">v</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0_</span><span class="k">i32</span><span class="p">;</span><span class="w"></span>
<span class="kd">let</span><span class="w"> </span><span class="n">ptr</span>: <span class="o">*</span><span class="k">const</span><span class="w"> </span><span class="kt">i32</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">&amp;</span><span class="n">v</span><span class="p">;</span><span class="w"></span>
<span class="kd">let</span><span class="w"> </span><span class="n">y</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">&amp;</span><span class="k">mut</span><span class="w"> </span><span class="n">v</span><span class="p">;</span><span class="w"> </span><span class="o">*</span><span class="n">y</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span><span class="w"></span>
<span class="kd">let</span><span class="w"> </span><span class="n">_z</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">unsafe</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="o">*</span><span class="n">ptr</span><span class="w"> </span><span class="p">};</span><span class="w"></span>
</pre></div>



<a name="169300397"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169300397" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169300397">(Jun 29 2019 at 14:48)</a>:</h4>
<blockquote>
<p>I suppose that the first example is OK in C, because the access doesn't happen in the scope of the restrict pointer, but this is also UB in C:</p>
</blockquote>
<p>in C it's not really clear what <code>restrict</code> means when not used as a function argument, I think</p>



<a name="169300490"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169300490" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169300490">(Jun 29 2019 at 14:50)</a>:</h4>
<p>So if you have *mut and then use .as_mut to get &amp;mut and then pass that to a function, and then the function returns... your *mut is dead so you just lost your value?</p>



<a name="169300506"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169300506" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169300506">(Jun 29 2019 at 14:51)</a>:</h4>
<p>I think what you are basically saying is that raw pointers should exist "next to" the tracking that knows which references got "derived from" which other reference and so on... the problem with that is that you can create a reference from a raw pointer, and we have to know where that reference "comes from"</p>



<a name="169300511"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169300511" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169300511">(Jun 29 2019 at 14:51)</a>:</h4>
<blockquote>
<p>So if you have *mut and then use .as_mut to get &amp;mut and then pass that to a function, and then the function returns... your *mut is dead so you just lost your value?</p>
</blockquote>
<p>if you create the <code>&amp;mut</code> <em>from</em> the <code>*mut</code> you are fine</p>



<a name="169300556"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169300556" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169300556">(Jun 29 2019 at 14:52)</a>:</h4>
<p>it's all about where the pointers "come from" being well-nested</p>



<a name="169300560"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169300560" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169300560">(Jun 29 2019 at 14:52)</a>:</h4>
<p>for your program, it's more like a tree... hm not sure how to draw that here</p>



<a name="169300565"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169300565" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169300565">(Jun 29 2019 at 14:52)</a>:</h4>
<p>yes, pointers next to references is the mental model that most people using unsafe code that I've spoken to subscribe to</p>



<a name="169300571"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169300571" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169300571">(Jun 29 2019 at 14:53)</a>:</h4>
<p>the root is v. <code>ptr</code> is one child of <code>v</code> and <code>y</code> is another child of <code>v</code>. they exist next to each other and thus are in conflict</p>



<a name="169300576"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169300576" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169300576">(Jun 29 2019 at 14:53)</a>:</h4>
<p>whereas if you make <code>y</code> a child of <code>v</code>, the situation is very different</p>



<a name="169300585"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169300585" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169300585">(Jun 29 2019 at 14:53)</a>:</h4>
<blockquote>
<p>yes, pointers next to references is the mental model that most people using unsafe code that I've spoken to subscribe to</p>
</blockquote>
<p>but then what happens when you create a reference again? you have to "put it somewhere"</p>



<a name="169300588"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169300588" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169300588">(Jun 29 2019 at 14:53)</a>:</h4>
<p>and that requires tracking raw pointers as well</p>



<a name="169300598"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169300598" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169300598">(Jun 29 2019 at 14:54)</a>:</h4>
<p>like... let me see if I can make an example</p>



<a name="169300654"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169300654" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169300654">(Jun 29 2019 at 14:55)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="kd">let</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">&amp;</span><span class="k">mut</span><span class="w"> </span><span class="mi">42</span><span class="p">;</span><span class="w"></span>
<span class="kd">let</span><span class="w"> </span><span class="n">y</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="o">*</span><span class="k">mut</span><span class="w"> </span><span class="n">_</span><span class="p">;</span><span class="w"> </span><span class="c1">// y derived from x</span>
<span class="kd">let</span><span class="w"> </span><span class="n">z</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">&amp;</span><span class="k">mut</span><span class="w"> </span><span class="o">*</span><span class="n">y</span><span class="p">;</span><span class="w"> </span><span class="c1">// z derived from y.</span>
<span class="o">*</span><span class="n">y</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">14</span><span class="p">;</span><span class="w"> </span><span class="c1">// this has to make z invalid! if we used z again there was an access between creating it and using it, a clear aliasing violation.</span>
<span class="c1">// however, x remains valid, because y was &quot;created from&quot; x so x &quot;knows&quot; that mutations can happen through y.</span>
<span class="o">*</span><span class="n">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">14</span><span class="p">;</span><span class="w"> </span><span class="c1">// however, now x may again assume that no mutations through anything else can happen.</span>
</pre></div>



<a name="169300697"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169300697" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169300697">(Jun 29 2019 at 14:56)</a>:</h4>
<p>the only way I know to explain this is to say that y is "between" x and z</p>



<a name="169300906"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169300906" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169300906">(Jun 29 2019 at 15:02)</a>:</h4>
<p>okay i see what you're saying, but, if i had my way, *y=14 is UB since z is live, and the rest of the program is unimportant once that happens</p>



<a name="169300992"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169300992" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169300992">(Jun 29 2019 at 15:04)</a>:</h4>
<p>That seems even worse for unsafe code authors?</p>



<a name="169300994"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169300994" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169300994">(Jun 29 2019 at 15:04)</a>:</h4>
<p>not that there couldn't be another model, there is apparently another model already, but you should post BUG HUGE signs about this sort of thing because most people are currently living under a model where addresses (only) are what matter, not any kind of source chain</p>



<a name="169301117"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169301117" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169301117">(Jun 29 2019 at 15:08)</a>:</h4>
<p><span class="user-mention" data-user-id="124289">@rkruppe</span> no it's a really easy model for unsafe code authors: "is anyone else referencing this address <em>right now</em>? (no) is it aligned and a valid bit pattern and all that? (yes) Okay I can make a &amp;mut pointing at it and once I'm sure that &amp;mut is gone nothing else about my program is different."</p>



<a name="169301336"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169301336" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169301336">(Jun 29 2019 at 15:14)</a>:</h4>
<blockquote>
<p>okay i see what you're saying, but, if i had my way, *y=14 is UB since z is live, and the rest of the program is unimportant once that happens</p>
</blockquote>
<p>that's weird, because this is <em>safe</em>:</p>
<div class="codehilite"><pre><span></span>let x = &amp;mut 42;
let y = &amp;mut *x; // y derived from x
let z = &amp;mut *y; // z derived from y.
*y = 14;
*x = 14;
</pre></div>



<a name="169301344"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169301344" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169301344">(Jun 29 2019 at 15:14)</a>:</h4>
<blockquote>
<p>not that there couldn't be another model, there is apparently another model already, but you should post BUG HUGE signs about this sort of thing because most people are currently living under a model where addresses (only) are what matter, not any kind of source chain</p>
</blockquote>
<p>well most people are wrong in many ways ;)</p>



<a name="169301351"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169301351" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169301351">(Jun 29 2019 at 15:14)</a>:</h4>
<p>and even your model makes the source matter</p>



<a name="169301360"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169301360" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169301360">(Jun 29 2019 at 15:15)</a>:</h4>
<p>if I used <code>z</code> instead of <code>y</code> I assume you are fine, even though both point to the same address</p>



<a name="169301362"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169301362" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169301362">(Jun 29 2019 at 15:15)</a>:</h4>
<p><span class="user-mention" data-user-id="224471">@Lokathor</span>  That is not the direction I'm worried about. You seem to suggest that creating raw pointers from a mutable reference and using them always causes UB, even if the mutable reference is not used while the raw pointer(s) are in use. On its face that seems to outlaw lots of unsafe code that should obviously work, e.g.:</p>
<div class="codehilite"><pre><span></span><span class="kd">let</span><span class="w"> </span><span class="n">some_memory</span>: <span class="kp">&amp;</span><span class="nc">mut</span><span class="w"> </span><span class="n">Foo</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">...;</span><span class="w"></span>
<span class="n">ptr</span>::<span class="n">write</span><span class="p">(</span><span class="n">some_memory</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="o">*</span><span class="k">mut</span><span class="w"> </span><span class="n">Foo</span><span class="p">,</span><span class="w"> </span><span class="nb">Default</span>::<span class="n">default</span><span class="p">());</span><span class="w"></span>
</pre></div>



<a name="169301367"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169301367" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169301367">(Jun 29 2019 at 15:15)</a>:</h4>
<blockquote>
<p><span class="user-mention silent" data-user-id="124289">rkruppe</span> no it's a really easy model for unsafe code authors: "is anyone else referencing this address <em>right now</em>? (no) is it aligned and a valid bit pattern and all that? (yes) Okay I can make a &amp;mut pointing at it and once I'm sure that &amp;mut is gone nothing else about my program is different."</p>
</blockquote>
<p>what does it mean "referencing right now"? in my safe example we have three references to the same thing, so it should be UB under your rules!</p>



<a name="169301485"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169301485" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169301485">(Jun 29 2019 at 15:19)</a>:</h4>
<p>oh i see, i read Ralf's example wrong</p>



<a name="169301490"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169301490" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169301490">(Jun 29 2019 at 15:19)</a>:</h4>
<p>i should never look at code on my phone, my brain doesn't format it right somehow</p>



<a name="169301528"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169301528" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169301528">(Jun 29 2019 at 15:20)</a>:</h4>
<p>^^</p>



<a name="169301537"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169301537" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169301537">(Jun 29 2019 at 15:20)</a>:</h4>
<p>I'll have to review and think again later today</p>



<a name="169301538"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169301538" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169301538">(Jun 29 2019 at 15:20)</a>:</h4>
<p>Stacked Borrows tries to formalize a notion that is like "liveness", but we cannot use literal liveness because that's a static thing</p>



<a name="169301541"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169301541" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169301541">(Jun 29 2019 at 15:20)</a>:</h4>
<p>at the <code>*y = 14</code> we dont know yet if <code>z</code> is live as we cannot predict if it gets used in the future</p>



<a name="169301543"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169301543" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169301543">(Jun 29 2019 at 15:21)</a>:</h4>
<p>and I'd rather not make UB at one point depend on what the program does in the future^^ that route lies madness</p>



<a name="169301553"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169301553" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169301553">(Jun 29 2019 at 15:21)</a>:</h4>
<p>(I am aware that UB is atemporal, but this would be <em>far worse</em>)</p>



<a name="169301677"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169301677" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169301677">(Jun 29 2019 at 15:25)</a>:</h4>
<p>so, what I've seen many people do is imagine it all as being similar to how drop works</p>



<a name="169301685"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169301685" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169301685">(Jun 29 2019 at 15:25)</a>:</h4>
<p>if &amp;mut is in scope, even if it's not used later, it's illegal to violate the rules, it hasn't "dropped" yet</p>



<a name="169302139"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169302139" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169302139">(Jun 29 2019 at 15:40)</a>:</h4>
<p>that's incompatible with NLL though</p>



<a name="169302143"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169302143" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169302143">(Jun 29 2019 at 15:40)</a>:</h4>
<p>since NLL, reference lifetime has nothing to do with scopes any more</p>



<a name="169302145"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169302145" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169302145">(Jun 29 2019 at 15:41)</a>:</h4>
<p>I tried implementing something "drop-like" some years ago: <a href="https://www.ralfj.de/blog/2017/07/17/types-as-contracts.html" target="_blank" title="https://www.ralfj.de/blog/2017/07/17/types-as-contracts.html">https://www.ralfj.de/blog/2017/07/17/types-as-contracts.html</a></p>



<a name="169302148"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169302148" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169302148">(Jun 29 2019 at 15:41)</a>:</h4>
<p>it didnt work</p>



<a name="169303964"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169303964" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169303964">(Jun 29 2019 at 16:37)</a>:</h4>
<p>I find the current model intuitive. If I look at a pointer or a reference, I just need to walk up its ancestors, checking if they had other children that might have invalidated the reference i'm studying</p>



<a name="169304007"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169304007" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169304007">(Jun 29 2019 at 16:38)</a>:</h4>
<p>(deleted)</p>



<a name="169308773"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169308773" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169308773">(Jun 29 2019 at 19:12)</a>:</h4>
<p>Well once it's explained it mostly makes sense</p>



<a name="169309236"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169309236" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169309236">(Jun 29 2019 at 19:26)</a>:</h4>
<p>but this might need a PSA post, is I guess what I'm saying</p>
<p>"Hey, a lot of yall think it works like X, but really the rules are more like Y. This isn't even a change, it's been like this for a while now."</p>



<a name="169309303"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169309303" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matt Taylor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169309303">(Jun 29 2019 at 19:29)</a>:</h4>
<p>definitely agree. seems to be a lot of confusion</p>



<a name="169309435"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169309435" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169309435">(Jun 29 2019 at 19:32)</a>:</h4>
<p>The rules aren't RFCed yet, so until that happens, its only interesting if you are using miri to find UB in your code</p>



<a name="169309449"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169309449" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169309449">(Jun 29 2019 at 19:33)</a>:</h4>
<p>Even if the rules are RFC'ed, many users don't really need to know them</p>



<a name="169309458"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169309458" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169309458">(Jun 29 2019 at 19:34)</a>:</h4>
<p>And from those who need to, listening to miri might be enough</p>



<a name="169309675"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169309675" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169309675">(Jun 29 2019 at 19:40)</a>:</h4>
<p>Once the rules are written somewhere, learning all of this will be easier</p>



<a name="169311591"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169311591" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169311591">(Jun 29 2019 at 20:46)</a>:</h4>
<p>right, these are the current WIP rules</p>



<a name="169311599"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169311599" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169311599">(Jun 29 2019 at 20:47)</a>:</h4>
<p>the relevant posts are on my blog, they did get announced on reddit + IRLO</p>



<a name="169311603"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169311603" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169311603">(Jun 29 2019 at 20:47)</a>:</h4>
<p>but nothing is official at this point</p>



<a name="169311607"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169311607" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169311607">(Jun 29 2019 at 20:47)</a>:</h4>
<p>and it seems like anyway the rules will have to change again...</p>



<a name="169321467"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169321467" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169321467">(Jun 30 2019 at 02:41)</a>:</h4>
<p>If people are triggering UB because they're writing code according to a different memory model than is the actual one, <em>everyone</em> cares about that.</p>
<p>Let me put it another way: Lots of people write unsafe code, few of them use miri on that code because it's "obviously" already correct.</p>
<p><em>Even if</em> the current rules are only temporary and subject to change later, people deserve to know what the current rules are at all times. Like, the usual Rust policy of saying little until one final ultimate stability push is over and done with, and then announcing however it ended, is a very bad plan in this situation.</p>
<p>Yall are great, but people are out there footgunning themselves today, they don't wait for you to do anything, they just push unsound code like there's no tomorrow. Educational materials should be spread sooner, not later.</p>



<a name="169332100"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169332100" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169332100">(Jun 30 2019 at 09:11)</a>:</h4>
<p>well I don't know what to do beyond writing blog posts and helping answer questions here. it's not like the rules are secret or anything.</p>
<blockquote>
<p>the usual Rust policy of saying little until one final ultimate stability push is over and done with</p>
</blockquote>
<p>this is unfair. first of all that's not at all the usual Rust policy, there is <em>so much</em> discussion everywhere, but of course if you wait until it appears on the official blog you won't see it. that's not what the official blog is for.<br>
and secondly if we were to assign Stacked Borrows into the usual Rust process, it would be pre-RFC or pre-pre-RFC. there's not usually anything in the official channels or docs at that stage for <em>any</em> proposal, and rightly so. the official channels would drown in noise otherwise.</p>
<p>we <em>do</em> have educational material that says "references have strict aliasing rules, we dont know the rules yet so be conservative". I don't think we can do much more on the official docs at this point in time. if people insist on ignoring that and instead doing things that are "obviously correct", I don't know what we can do about that.</p>



<a name="169332150"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169332150" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169332150">(Jun 30 2019 at 09:12)</a>:</h4>
<p>if we say <em>anything</em> like "the following thing is okay to do with raw pointers and references", that's a <em>big commitment</em></p>



<a name="169332214"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169332214" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169332214">(Jun 30 2019 at 09:14)</a>:</h4>
<p>I guess we could have a "negative list" somewhere -- "the following things might seem obvious but they are not, don't do that". and maybe hopefully that list wont just be ignored because it contains so many things that people want to do...</p>



<a name="169332242"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169332242" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169332242">(Jun 30 2019 at 09:15)</a>:</h4>
<p>but I also have to add that I am at max capacity with what I am doing with Stacked Borrows and Miri and the Unsafe Code Guidelines currently. there's only so much one person can do in a day. (Not saying I am doing all of that alone, but Stacked Borrows so far has been mostly me -- it's also very complicated to get into so I am not blaming anyone. And some people have helped tremendously developing the model.)</p>



<a name="169332546"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169332546" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169332546">(Jun 30 2019 at 09:25)</a>:</h4>
<p>Help writing more educational material is certainly welcome though. :-)<br>
Of course, that all needs to be updated whenever things change, and they will... writing such things early costs a lot of resources that we currently just don't have.</p>



<a name="169343293"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169343293" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169343293">(Jun 30 2019 at 15:11)</a>:</h4>
<p>I don't think that you need to say "you can do this with raw pointers (now and for all time)". I think you just need to say "as of precisely June 30th of 2019, this is what you can do with raw pointers (and this is all "unstable, implementation defined" and can all change at any moment)".</p>
<p>I'm fairly good at putting out very large word counts of materials as necessary. If you were interested in setting up a place for "what we think the rules currently mean" to be written down I could probably fill in the prose parts in between some select code examples like the little 4 line example we had above. Vetting it for accuracy would still fall on the WG members. I'm not thinking that it has to be too complex, probably a single markdown file could cover it until things move from at least "pre-pre-RFC" up to "pre-RFC" or better.</p>
<p>We could have great examples such as "aliasing or not actually depends on the parentage of where the pointer/reference comes from" and "no, you currently cannot make a slice of uninitialized memory as a buffer to write to, please stop doing that"</p>



<a name="169343446"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169343446" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169343446">(Jun 30 2019 at 15:15)</a>:</h4>
<p>in terms of placement, sounds like a nomicon thing to me?</p>
<blockquote>
<p>"no, you currently cannot make a slice of uninitialized memory as a buffer to write to, please stop doing that"</p>
</blockquote>
<p>that's unrelated to Stacked Borrows, but I guess that distinction is not very meaningful "from the outside"</p>



<a name="169344459"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169344459" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169344459">(Jun 30 2019 at 15:46)</a>:</h4>
<p>I mean that stacked borrows aren't the only thing that people regularly do wrong :)</p>
<p>And yeah, maybe a "grab bag" page in the Nomicon would fit this situation.</p>



<a name="169344793"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169344793" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169344793">(Jun 30 2019 at 15:57)</a>:</h4>
<blockquote>
<p>I mean that stacked borrows aren't the only thing that people regularly do wrong :)</p>
</blockquote>
<p>sure. and while we have a lot of docs about what you <em>can</em> do, its much less clearer where to put docs about what you <em>cannot</em> do</p>



<a name="169344797"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169344797" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169344797">(Jun 30 2019 at 15:57)</a>:</h4>
<p>these days, at least the docs for <code>MaybeUninit</code> and <code>mem::uninitialized</code> call out that you cant just run around with uninitialized memory</p>



<a name="169344799"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169344799" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169344799">(Jun 30 2019 at 15:57)</a>:</h4>
<p>(on beta currently, will hit stable next week)</p>



<a name="169344841"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169344841" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169344841">(Jun 30 2019 at 15:58)</a>:</h4>
<p>those might be good docs for you to look over and suggest ho they could be improved, maybe?</p>



<a name="169345688"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169345688" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169345688">(Jun 30 2019 at 16:25)</a>:</h4>
<p>Sure, I'll have a look. I think my usual writing style is a bit more like the Nomicon or Too Many Linked Lists style than like the libstd style.</p>
<p>The other problem is that some of this stuff is <em>currently</em> one way but as you say not really set in stone. For example, <a href="https://github.com/rust-lang/unsafe-code-guidelines/issues/71" target="_blank" title="https://github.com/rust-lang/unsafe-code-guidelines/issues/71">https://github.com/rust-lang/unsafe-code-guidelines/issues/71</a> might make advice against uninit <code>&amp;[u8]</code> obsolete eventually. In this case, people might use old compiler versions of course (eg: debian stable will be 1.34 for a long while), so <em>those versions</em> will need the old info of course. I'm not super clear how the libs/docs team feels about supplimental docs that need to change over time like that.</p>



<a name="169346088"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169346088" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169346088">(Jun 30 2019 at 16:38)</a>:</h4>
<blockquote>
<p>In this case, people might use old compiler versions of course (eg: debian stable will be 1.34 for a long while), so those versions will need the old info of course. </p>
</blockquote>
<p>actually, at least in this case, that's not true. the compiler is <em>already</em> compatible with a spec that says "integers may be uninitialized as long as you dont do any arithmetic or so on them"</p>



<a name="169346089"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169346089" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169346089">(Jun 30 2019 at 16:38)</a>:</h4>
<p>we just dont want to commit to that yet</p>



<a name="169346092"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169346092" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169346092">(Jun 30 2019 at 16:38)</a>:</h4>
<p>but once we do, this becomes retroactively correct for old compilers</p>



<a name="169346167"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169346167" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matt Taylor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169346167">(Jun 30 2019 at 16:41)</a>:</h4>
<p>i would personally like a bit more clarity on these two pages in particular <a href="https://doc.rust-lang.org/reference/behavior-considered-undefined.html" target="_blank" title="https://doc.rust-lang.org/reference/behavior-considered-undefined.html">https://doc.rust-lang.org/reference/behavior-considered-undefined.html</a> <a href="https://doc.rust-lang.org/nomicon/aliasing.html" target="_blank" title="https://doc.rust-lang.org/nomicon/aliasing.html">https://doc.rust-lang.org/nomicon/aliasing.html</a></p>



<a name="169346171"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169346171" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matt Taylor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169346171">(Jun 30 2019 at 16:41)</a>:</h4>
<p>the nomicon page currently only talks about references</p>



<a name="169346345"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169346345" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matt Taylor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169346345">(Jun 30 2019 at 16:46)</a>:</h4>
<p>and the reference basically says ‘pointers are like C, check llvm noalias docs for references’ - which is a problem because 1) noalias suggests there’s only a problem on <em>accesses</em> through noalias’d pointers, yet as per my original example it can be UB just by creating a &amp;mut T and not using it at all and 2) it doesn’t detail the interaction between pointers and refs</p>



<a name="169346360"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169346360" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matt Taylor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169346360">(Jun 30 2019 at 16:47)</a>:</h4>
<p>if i knew all the details in my head of C’s model and LLVM’s noalias i could probably figure that out for myself but people shouldn’t have to dig that far to see what’s allowed</p>



<a name="169346615"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169346615" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169346615">(Jun 30 2019 at 16:55)</a>:</h4>
<p>I agree</p>



<a name="169348028"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169348028" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169348028">(Jun 30 2019 at 17:41)</a>:</h4>
<p>the reference page seems good already</p>



<a name="169348031"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169348031" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169348031">(Jun 30 2019 at 17:41)</a>:</h4>
<p>i mean, it's clearly needing more info later, but at the moment, the things it does say are relatively clear</p>



<a name="169348073"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169348073" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169348073">(Jun 30 2019 at 17:42)</a>:</h4>
<p>the nomicon page... leaves a bit to be desired i think</p>



<a name="169348090"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169348090" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169348090">(Jun 30 2019 at 17:43)</a>:</h4>
<p>If i have time later today, and I think I will, then I'll make an attempt at expanding that page a bit as my first programming priority of the day</p>



<a name="169348606"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169348606" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169348606">(Jun 30 2019 at 17:59)</a>:</h4>
<p>thanks <span class="user-mention" data-user-id="224471">@Lokathor</span> :)<br>
I can help reviewing, though I dont have any r+ powers for the reference or the nomicon. but we'll find someone who does.^^</p>



<a name="169348754"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169348754" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169348754">(Jun 30 2019 at 18:02)</a>:</h4>
<p>I would have guessed the Nomicon to be under the direct control of the unsafe wg</p>



<a name="169348877"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169348877" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169348877">(Jun 30 2019 at 18:07)</a>:</h4>
<p>no, the nomicon is waay older than we are</p>



<a name="169348880"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169348880" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169348880">(Jun 30 2019 at 18:07)</a>:</h4>
<p>and we dont have anything directly to do with it.</p>



<a name="169348881"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169348881" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169348881">(Jun 30 2019 at 18:07)</a>:</h4>
<p>but that sounds like a thing we might want to change :D</p>



<a name="169348922"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169348922" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169348922">(Jun 30 2019 at 18:08)</a>:</h4>
<p>the problem is, the WG doesnt really have any leftover bandwidth. we can barely keep our discussions going...</p>



<a name="169354202"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169354202" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169354202">(Jun 30 2019 at 21:04)</a>:</h4>
<p>assimilate more members</p>



<a name="169357478"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169357478" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169357478">(Jun 30 2019 at 23:00)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> <a href="https://github.com/rust-lang-nursery/nomicon/pull/144" target="_blank" title="https://github.com/rust-lang-nursery/nomicon/pull/144">https://github.com/rust-lang-nursery/nomicon/pull/144</a> is a very small edit to just the readme, just to get my feet wet since I haven't really PR'd at repo other than my own in a while. But it's a start</p>



<a name="169413567"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/169413567" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#169413567">(Jul 01 2019 at 17:22)</a>:</h4>
<p>thanks :)</p>



<a name="171267195"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/171267195" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ehsan M. Kermani <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#171267195">(Jul 19 2019 at 15:29)</a>:</h4>
<p>May I ask what is "niches" that was discussed here?</p>



<a name="171268043"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/171268043" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#171268043">(Jul 19 2019 at 15:39)</a>:</h4>
<p>See <a href="https://rust-lang.github.io/unsafe-code-guidelines/glossary.html#niche" target="_blank" title="https://rust-lang.github.io/unsafe-code-guidelines/glossary.html#niche">https://rust-lang.github.io/unsafe-code-guidelines/glossary.html#niche</a></p>



<a name="171272045"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/171272045" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ehsan M. Kermani <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#171272045">(Jul 19 2019 at 16:33)</a>:</h4>
<p>Ah, thanks! <br>
Just to make sure about the linked doc, type repr includes size, alignment, niches and abi and having these 4 defines a valid type? In other words, is it always a one-to-four relation?</p>



<a name="171273347"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/171273347" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#171273347">(Jul 19 2019 at 16:49)</a>:</h4>
<p>repr(esentation) is overloaded and not currently defined in the glossary. I'm not sure what exactly the underlying question is to answer it directly. Certainly there is more a "type" than just these four things. Even for data layout considerations, the location (offsets) of the fields contained in it are important as well.</p>



<a name="171273674"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/171273674" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ehsan M. Kermani <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#171273674">(Jul 19 2019 at 16:53)</a>:</h4>
<p>Ok, just want to have a correct mental model of the constituents. So anything more than (size, align, offset, niche, abi) + underlying validity requirments?</p>



<a name="171274624"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/171274624" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#171274624">(Jul 19 2019 at 17:05)</a>:</h4>
<p>Hm. I don't want to commit to that being exhaustive but it's roughly all I can think of that comes up in the current discussions.</p>



<a name="171322997"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/171322997" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#171322997">(Jul 20 2019 at 11:03)</a>:</h4>
<p><span class="user-mention" data-user-id="211549">@Ehsan M. Kermani</span> there's also the validity invariant! What exactly that invariant is for various types is currently being discussed.</p>



<a name="171323001"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/171323001" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#171323001">(Jul 20 2019 at 11:03)</a>:</h4>
<p>see <a href="https://github.com/rust-lang/unsafe-code-guidelines/blob/master/active_discussion/validity.md" target="_blank" title="https://github.com/rust-lang/unsafe-code-guidelines/blob/master/active_discussion/validity.md">https://github.com/rust-lang/unsafe-code-guidelines/blob/master/active_discussion/validity.md</a> and <a href="https://github.com/rust-lang/unsafe-code-guidelines/issues?q=is%3Aissue+is%3Aopen+label%3Atopic-validity" target="_blank" title="https://github.com/rust-lang/unsafe-code-guidelines/issues?q=is%3Aissue+is%3Aopen+label%3Atopic-validity">https://github.com/rust-lang/unsafe-code-guidelines/issues?q=is%3Aissue+is%3Aopen+label%3Atopic-validity</a></p>



<a name="171539002"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/171539002" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ehsan M. Kermani <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#171539002">(Jul 23 2019 at 17:25)</a>:</h4>
<p>In light of niches discussion, I don't think the name is representative enough. In cases like boolian, it's not "niches" per say!</p>



<a name="171552053"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/171552053" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#171552053">(Jul 23 2019 at 19:51)</a>:</h4>
<p>I do not understand what you are trying to say?</p>



<a name="171554479"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/171554479" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ehsan M. Kermani <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#171554479">(Jul 23 2019 at 20:20)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> I'm trying to see if there's a better name instead of "niche" <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="171557541"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/171557541" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#171557541">(Jul 23 2019 at 21:01)</a>:</h4>
<p>ah. well there probably is but that'd be a discussion to have with @eddyb and t-compiler -- "niche" is what rustc calls it internally ;)</p>



<a name="171558522"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/171558522" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tom Phinney <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#171558522">(Jul 23 2019 at 21:14)</a>:</h4>
<p>IMO as a native American English speaker, "niche" is about as good a term as we are likely to find.</p>



<a name="171571395"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/171571395" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#171571395">(Jul 24 2019 at 01:39)</a>:</h4>
<p>Just try to get two people to agree on a pronunciation of "niche"</p>



<a name="171573318"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/171573318" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tom Phinney <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#171573318">(Jul 24 2019 at 02:33)</a>:</h4>
<p>It's like "cache" <span aria-label="rolling on the floor laughing" class="emoji emoji-1f923" role="img" title="rolling on the floor laughing">:rolling_on_the_floor_laughing:</span></p>



<a name="171573382"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/171573382" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tom Phinney <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#171573382">(Jul 24 2019 at 02:35)</a>:</h4>
<p>Of course, it really isn't; the terminal consonant is pronounced differently. But just as there are many pronunciations of "cache", there certainly will be similar variety with "niche".</p>



<a name="171585408"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/171585408" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> HeroicKatora <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#171585408">(Jul 24 2019 at 07:48)</a>:</h4>
<p>Pronouncing it 'nitch' or 'nish' instead of <code>neesh</code> is passing on a perfectly justified opportunity for speaking French <span aria-label="wink" class="emoji emoji-1f609" role="img" title="wink">:wink:</span></p>



<a name="171616288"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/171616288" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tom Phinney <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#171616288">(Jul 24 2019 at 15:32)</a>:</h4>
<p>You're right, of course. That's also how it's pronounced in the UK. However, in much of the US it's pronounced "nitch". See <a href="https://www.quickanddirtytips.com/education/grammar/how-do-you-pronounce-niche" target="_blank" title="https://www.quickanddirtytips.com/education/grammar/how-do-you-pronounce-niche">https://www.quickanddirtytips.com/education/grammar/how-do-you-pronounce-niche</a> and <a href="https://www.google.com/search?q=Dictionary#dobs=niche" target="_blank" title="https://www.google.com/search?q=Dictionary#dobs=niche">https://www.google.com/search?q=Dictionary#dobs=niche</a>. If we want to encourage a uniform pronunciation for Rustaceans, the it would be best to include parenthetical pronunciation, such as "(preferably pronounced nēSH)", at the first occurrence of the word in various major Rust teaching documents.</p>



<a name="171620783"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/171620783" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#171620783">(Jul 24 2019 at 16:29)</a>:</h4>
<p>FWIW I always found it funny at conferences to hear how different people pronounce the different technical words</p>



<a name="171620876"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/171620876" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#171620876">(Jul 24 2019 at 16:30)</a>:</h4>
<p>I don't recall the differences in pronunciation ever being a problem, more like a curiosity</p>



<a name="171620910"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/171620910" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#171620910">(Jul 24 2019 at 16:31)</a>:</h4>
<p>e.g. some people pronounce <code>std</code> as "stood", while others say "standard" and others say "es-tee-dee"</p>



<a name="171621067"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/171621067" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#171621067">(Jul 24 2019 at 16:33)</a>:</h4>
<p>if we choose "niche" I don't really have a problem with people pronouncing it however they want, i really can't see the different pronunciations leading to communication problems, at most some people will get a laugh</p>



<a name="171624047"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification%3A%20Can%20you%20have%20%26T%20and%20%2Amut%20T%20point%20at%20the%20sa.../near/171624047" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Clarification.3A.20Can.20you.20have.20.26T.20and.20*mut.20T.20point.20at.20the.20sa.2E.2E.2E.html#171624047">(Jul 24 2019 at 17:09)</a>:</h4>
<blockquote>
<p>e.g. some people pronounce <code>std</code> as "stood", while others say "standard" and others say "es-tee-dee"</p>
</blockquote>
<p>I don't have any vowel in my version of <code>std</code>, its just "shtd"</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>